#include "SetStage.h"
#include "global.h"
#include "SimpleAudioEngine.h"
void SetStage::destroy()
{
    // the.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    // the.parent.removeChild(the);
    // the.kill();
    // MyMain.instance.remove(the);
    this->getParent()->removeChild(this, true);
    //MySound.start.play();
	//map_changeplay(true);
    
	global_instance->initMyTank();
    global_instance->scheduleUpdate();map_isPlay=true;
   
}

SetStage::SetStage(int level)
{

 /*   CCSprite* bg = CCSprite::create("setbg.png");
    bg->setAnchorPoint(ccp(0, 0));
    addChild(bg);*/
	 if (global_sound) {
                //todo SoundEngine.playEffect(Resource.s_buttonEffect);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("SoundStart.mp3");
    }
    this->m_target=CCRenderTexture::create(420,700);
	//m_target->setAnchorPoint(ccp(0,0));
	m_target->setPosition(ccp(210,350));
    m_target->clear(.5,.5,.5,1);
    //m_target->begin();
    
	//::glLineWidth(2);
	//::glColor4f(color.r,color.g,color.b,color.a);
	//::ccDrawCircle(ccp(0,0), 8,360,8,true);
	//m_target->end();
    addChild(m_target);
    this->_lblife = CCLabelBMFont::create("life 5","font1.fnt");// CCLabelTTF::labelWithString("0",
	_lblife->setPosition(ccp(210,350));
	_lblife->setColor(ccc3(255, 255, 255));
	addChild(_lblife);
	_lblife->setScaleX(0.7);
	_lblife->setScaleY(0.7);
    sprintf(tmpbuffer,"stage %d",level);
	_lblife->setString(tmpbuffer);
    //num->draw(level);
    this->runAction(CCSequence::create(
                                        CCDelayTime::create(3.0f),
                                        CCCallFunc::create(this, callfunc_selector(SetStage::destroy)),NULL));

}

